<template>

	<div>


		<div class="smp-result smp_panel_1" v-if="allList.applySystemList.length>0">
			<div class="smp_panel_header">
				<div class="smp_panel_pre"></div>
				<div class="smp_panel_title">系统维护</div>
				<div class="smp-panel_option">

				</div>
			</div>
			<div class="applySystemList smp_panel_body" v-if="allList.applySystemList.length>0">
				<el-table :data="allList.applySystemList" size="mini" stripe border style="width: 100%">
					<el-table-column prop="systemName" label="系统名称" align="center"></el-table-column>
					<el-table-column prop="systemNo" label="系统编号" align="center"></el-table-column>
					<el-table-column prop="systemType" label="系统类别" align="center">
						<template slot-scope="scope">
							{{scope.row.systemType|dictName("SMP0014")}}
						</template>
					</el-table-column>
					<el-table-column prop="systemOrg" label="所属机构" align="center">
						<template slot-scope="scope">
							{{scope.row.systemOrg|getOrgNameByOrgCode}}
						</template>
					</el-table-column>
					<el-table-column prop="esbAddr" label="ESB测试IP" align="center" width="160">
						<template slot-scope="scope">
							<!-- {{scope.row.esbAddr|dictName("SMP0016")}} -->
							{{scope.row.esbAddr|getESBEnvironment(that)}}
						</template>
					</el-table-column>
					<el-table-column prop="testAddr" label="测试应用IP" align="center"></el-table-column>
					<!-- <el-table-column prop="prodAddr" label="生产应用IP" align="center"></el-table-column> -->
					<el-table-column prop="requireType" label="申请类型" align="center">
						<template slot-scope="scope">
							<el-tag size="mini"  type="info">
							{{scope.row.requireType|dictName("SMP0013")}}
							</el-tag>
						</template>
					</el-table-column>

					<el-table-column prop="status" label="配置状态" align="center" v-if="operate">
						<template slot-scope="scope">
							{{scope.row.status|dictName('SMP0028')}}
						</template>
					</el-table-column>

					<el-table-column label="" label="操作" align="center" width="150">
						<!-- <template slot="header">
								  <i class="el-icon-upload"></i>
								  操作
							  </template> -->


						<template slot-scope="scope">
							
							<el-link  size="mini" type="primary" :underline="false"
								style="font-size: 12px;" @click="systemview(scope.$index, scope.row)">详情</el-link>
							<template v-if="allList.requireApply.status==8">
								<el-divider direction="vertical"></el-divider>
							<el-link size="mini" type="primary" :underline="false"
								style="font-size: 12px;" @click="handleEdit1(scope.$index, scope.row)">系统详情</el-link>
										</template>
							<template v-if="scope.row.requireType=='01' && operate">
								<el-divider direction="vertical" v-if="allList.requireApply.status==8"></el-divider>

								<el-link size="mini" type="primary" :underline="false" style="font-size: 12px;"
									@click="system(scope.$index, scope.row)"><i class="el-icon-edit-outline" />配置
								</el-link>
							</template>
						</template>
					</el-table-column>
				</el-table>
			</div>
		</div>
		<!-- <el-divider content-position="left" /> -->

		<div class="smp-result smp_panel_1" v-if="allList.applyServerList.length>0">
			<div class="smp_panel_header">
				<div class="smp_panel_pre"></div>
				<div class="smp_panel_title">服务维护</div>
				<div class="smp-panel_option">
					<el-button @click="onSubmit" plain v-if="allList.applyServerList.length>0 && operate" type="success"
						size="mini">一键配置</el-button>
					<el-button @click="onapplyServerExport" plain  icon="el-icon-download"
							size="mini">导出</el-button>
				</div>
			</div>

			<div class="applyServerList smp_panel_body">
				<el-table
					:data="allList.applyServerList.slice((applyServerListCurrentPage-1)*applyServerListPageSize,applyServerListCurrentPage*applyServerListPageSize)"
					size="mini" stripe style="width: 100%">
					<el-table-column prop="transCode" label="交易码" align="center"></el-table-column>
					<el-table-column prop="transName" label="交易名称" align="center" show-overflow-tooltip>
					</el-table-column>
					<el-table-column prop="systemNo" label="服务系统" align="center" show-overflow-tooltip>
						<template slot-scope="scope">
							{{scope.row.systemNo|getSystemName}}({{scope.row.systemNo}})
						</template>
					</el-table-column>
					<el-table-column prop="busCode" label="服务编码" align="center"  width="120"></el-table-column>
					<el-table-column prop="msgAgreement" label="报文协议" align="center" width="100"></el-table-column>
					<el-table-column prop="msgCode" label="报文编码" align="center" width="80">
						<template slot-scope="scope">
							{{scope.row.msgCode|dictName('SMP0004')}}
						</template>
					</el-table-column>
					<el-table-column prop="httpMethed" label="http请求方法" align="center" width="100"></el-table-column>
					
					<!-- <el-table-column prop="testAddr" label="测试URL" show-overflow-tooltip align="center"></el-table-column>
				<el-table-column prop="prodAddr" label="生产URL" show-overflow-tooltip  align="center"></el-table-column> -->
					<el-table-column prop="outShow" label="外部可见" align="center" width="80">
						<template slot-scope="scope">
							{{scope.row.outShow|dictName('SMP0015')}}
						</template>
					</el-table-column>

					<el-table-column prop="pubCode" label="代理服务编码" width="120" align="center" show-overflow-tooltip>
						<template slot-scope="scope">
							{{scope.row.pubCode}}
						</template>
					</el-table-column>

					<el-table-column prop="outShow" label="申请类型" align="center">
						<template slot-scope="scope">
							<el-tag size="mini"  type="info">
								{{scope.row.requireType|dictName('SMP0013')}}
							</el-tag>
						</template>
					</el-table-column>
					<el-table-column prop="newTransCode" label="新交易码" align="center"></el-table-column>
					
					
					<!-- <el-table-column prop="funIntr" show-overflow-tooltip="true" label="功能简介"></el-table-column>
				 -->

					<el-table-column prop="configStatus" label="配置状态" align="center" v-if="operate" width="100px">

						<template slot-scope="scope">
							<el-tag type="success" size="mini" v-if="scope.row.configStatus=='02'">
								{{scope.row.configStatus|dictName('SMP0028')}}
							</el-tag>
							
							<el-tag type="warning" size="mini"  v-if="scope.row.configStatus=='01'">
								{{scope.row.configStatus|dictName('SMP0028')}}
							</el-tag>
						</template>
					</el-table-column>

					<el-table-column label="" label="操作" align="center" width="200">
						<template slot-scope="scope">
							<el-link size="mini" type="primary" :underline="false" style="font-size: 12px;"
								@click="handleEdit2(scope.$index, scope.row)">详情</el-link>
							<el-divider v-if="allList.requireApply.status==8" direction="vertical"></el-divider>
							<el-link v-if="allList.requireApply.status==8" size="mini" type="primary" :underline="false"
								style="font-size: 12px;" @click="handleEdit3(scope.$index, scope.row)">服务详情</el-link>

							<template>
								<!-- <template > -->
								<el-divider direction="vertical"></el-divider>
								<el-link size="mini" type="primary" :underline="false" style="font-size: 12px;"
									:disabled="scope.row.requireType!='02'"
									@click="versionComparison(scope.$index, scope.row)">版本比较</el-link>

							</template>

							<template v-if="scope.row.requireType=='01' && operate">
								<el-divider direction="vertical"></el-divider>
								<el-link size="mini" type="primary" :underline="false" style="font-size: 12px;"
									@click="registration(scope.$index, scope.row)">配置</el-link>
							</template>

						</template>
					</el-table-column>
				</el-table>
				<div class="smp-pagination">
					<el-pagination background size="medium" layout="total,sizes,prev, pager, next,jumper"
						:page-size="applyServerListPageSize" :page-sizes="[5,10,20]"
						:total="allList.applyServerList.length" :current-page="applyServerListCurrentPage"
						@current-change="applyServerListCurrentChange" @size-change="applyServerListSizeChange">
					</el-pagination>
				</div>
			</div>

		</div>

		<!-- <el-divider content-position="left" /> -->
		<div class="smp-result smp_panel_1" v-if="allList.applySystemCallList.length>0">
			<div class="smp_panel_header">
				<div class="smp_panel_pre"></div>
				<div class="smp_panel_title">服务调用</div>
				<div class="smp-panel_option">
					<el-button @click="commonConfig" plain v-if="allList.applySystemCallList.length>0 && operate" type="success"
						size="mini">公共配置</el-button>
				</div>
			</div>
			<div class="applySystemCallList smp_panel_body">
				<el-table
					:data="allList.applySystemCallList.slice((applySystemCallListCurrentPage-1)*applySystemCallListPageSize,applySystemCallListCurrentPage*applySystemCallListPageSize)"
					size="mini" stripe style="width: 100%">
					<!-- <el-table-column prop="regCode" label="服务编码(R)" align="center"></el-table-column> -->
					<el-table-column prop="transCode" label="交易码" align="center"></el-table-column width="120">
					<el-table-column prop="transName" label="交易名称" align="center" show-overflow-tooltip width="120">
					</el-table-column>
					<el-table-column prop="regSysCode" label="服务系统" align="center" show-overflow-tooltip width="120">
						<template slot-scope="scope">
							{{scope.row.regSysCode|getSystemName}}({{scope.row.regSysCode}})
						</template>
					</el-table-column>
					<el-table-column prop="pubSysCode" label="消费系统" align="center" show-overflow-tooltip width="120">
						<template slot-scope="scope">
							{{scope.row.pubSysCode|getSystemName}}({{scope.row.pubSysCode}})
						</template>
					</el-table-column>
					<!-- <el-table-column prop="channel" label="渠道号" width="120"></el-table-column> -->
					<el-table-column prop="msgAgreement" label="消费方报文格式" align="center" width="120"></el-table-column>
					<el-table-column prop="msgCode" label="消费方字符编码" align="center" width="120">
						<template slot-scope="scope">
							{{scope.row.msgCode|dictName('SMP0004')}}
						</template>
					</el-table-column>
					<el-table-column prop="pubCode" label="服务编码(P)" align="center" width="120" >

						<template slot-scope="scope">
							<span style="color: #67c23a;">{{scope.row.pubCode}}</span>
						</template>

					</el-table-column>
					<el-table-column prop="proxyPath" label="ESB测试URL" align="center" show-overflow-tooltip
						class-name="proxyPathClass">

						<template slot-scope="scope">
							<span style="color: #67c23a;">{{scope.row.proxyPath}}</span>
						</template>

					</el-table-column>
					<el-table-column prop="outShow" label="申请类型" align="center">
						<template slot-scope="scope">
							<el-tag size="mini" type="info">
								{{scope.row.requireType|dictName('SMP0013')}}
							</el-tag>
						</template>
					</el-table-column>
					<el-table-column prop="status" label="配置状态" align="center" v-if="operate" width="80">
						<template slot-scope="scope">
							
							<el-tag type="success" size="mini" v-if="scope.row.status=='02'">
								{{scope.row.status|dictName('SMP0028')}}
							</el-tag>
							
							<el-tag type="warning" size="mini"  v-if="scope.row.status=='01'">
								{{scope.row.status|dictName('SMP0028')}}
							</el-tag>
							
							
						</template>
					</el-table-column>

					<el-table-column label="操作" align="center" min-width="120">
						<template slot-scope="scope">



							<el-link size="mini" v-if="operate" type="primary" :underline="false"
								style="font-size: 12px;" @click="invocation(scope.$index, scope.row)"><i
									class="el-icon-edit-outline" />配置
							</el-link>
							<el-divider v-if="operate" direction="vertical"></el-divider>

							<el-link size="mini" type="primary" :underline="false" style="font-size: 12px;"
								@click="handleEdit4(scope.$index, scope.row)">服务详情</el-link>
						</template>
					</el-table-column>
				</el-table>

				<div class="smp-pagination">
					<el-pagination background size="medium" layout="total,sizes,prev, pager, next,jumper"
						:page-size="applySystemCallListPageSize" :page-sizes="[5,10,20,200]"
						:total="allList.applySystemCallList.length" :current-page="applySystemCallListCurrentPage"
						@current-change="applySystemCallListCurrentChange" @size-change="applySystemCallListSizeChange">
					</el-pagination>
				</div>

			</div>

		</div>


		<div class="smp-result smp_panel_1" v-if="allList.applyEnvironmentList.length>0">
			<div class="smp_panel_header">
				<div class="smp_panel_pre"></div>
				<div class="smp_panel_title">环境维护</div>
				<div class="smp-panel_option">

				</div>
			</div>
			<div class="applySystemCallList smp_panel_body">
				<el-table :data="allList.applyEnvironmentList" size="mini" stripe border style="width: 100%">
					<el-table-column prop="requireType" label="环境操作" align="center">
						<template slot-scope="scope">
							{{scope.row.requireType|dictName('SMP0025')}}
						</template>
					</el-table-column>
					<el-table-column prop="systemNo" label="系统名称" align="center">
						<template slot-scope="scope">
							{{scope.row.systemNo|getSystemName}}({{scope.row.systemNo}})
						</template>
					</el-table-column>
					<el-table-column prop="hostName" label="主机名称" align="center" />

					<el-table-column prop="envirType" label="环境类型" align="center">
						<template slot-scope="scope">
							{{scope.row.envirType|dictName("SMP0026")}}
						</template>
					</el-table-column>
					<el-table-column prop="esbAddr" label="关联ESB环境" align="center" width="160">
						<template slot-scope="scope">
							<!-- {{scope.row.esbAddr|dictName('SMP0016')}} -->
							{{scope.row.esbAddr|getESBEnvironment(that)}}
						</template>
					</el-table-column>
					<el-table-column prop="systemCurrentAddr" label="系统环境" align="center" />
					<el-table-column prop="systemTargetAddr" label="系统目标环境" align="center"></el-table-column>
					<el-table-column prop="hosts" label="HOSTS" align="center"></el-table-column>
					<el-table-column prop="configStatus" label="配置状态" align="center">
						<template slot-scope="scope">
							<el-tag type="success" size="mini" v-if="scope.row.configStatus=='02'">
								{{scope.row.configStatus|dictName('SMP0028')}}
							</el-tag>
							
							<el-tag type="warning" size="mini"  v-if="scope.row.configStatus=='01'">
								{{scope.row.configStatus|dictName('SMP0028')}}
							</el-tag>
							
							
							
						</template>
					</el-table-column>

					<el-table-column v-if="operate" align="center" width="150">
						<template slot="header">
							<i class="el-icon-upload"></i>
							操作
						</template>
						<template slot-scope="scope">

							<el-link v-if="scope.row.requireType != '03'" size="mini" type="primary" :underline="false"
								style="font-size: 12px;" @click="network(scope.$index, scope.row)">联通性测试</el-link>
							<el-divider v-if="scope.row.requireType != '03'"
								direction="vertical"></el-divider>
							<el-link v-if="scope.row.requireType != '03'" size="mini" type="primary" :underline="false"
								style="font-size: 12px;" @click="environment(scope.$index, scope.row)">配置
							</el-link>

						</template>
					</el-table-column>
				</el-table>
			</div>
		</div>

		<div class="smp-result smp_panel_1"  v-if="allList.requireApply.applyUser==activeUser">
			<div class="smp_panel_header">
				<div class="smp_panel_pre"></div>
				<div class="smp_panel_title">附件信息</div>
				<div class="smp-panel_option">
				</div>
			</div>
			<div class="smp_panel_body">
				<el-form :inline="false" label-width="80px" size="mini" ref="form1">
					<el-row>
						<el-col :span="8">
							<el-form-item label="附件:" label-width="80px" prop="aa" style="text-align: left;">
								<el-upload :on-change="changeFile" :before-upload="beforUpload"
											:show-file-list="false" multiple :auto-upload="false" :file-list="fileList"
											action="#">
											<!-- <i class="el-icon-upload"></i>
								<div class="el-upload__text">将文件拖至此处或<em>点击上传</em></div> -->
											<el-button style="width: 200px;" ><i class="el-icon-upload" />添加附件
											</el-button>
										</el-upload>
								<div v-for="item in fileList" class="fileList">
									<el-link @click="downFile(item)" type="success" :underline="false"><i
											class="el-icon-document"></i> {{item.name}}</el-link>
									<el-link type="success" @click="deleteFile(item)" :underline="false"
												style="float: right;">
												<i class="el-icon-close"></i>
											</el-link>
								</div>
							</el-form-item>
						</el-col>
						<el-col :span="8">
								<el-link @click="downTemplate"  size="mini" :underline="false"  style="margin-right:10px;float:left;"
									>
									<i class="el-icon-download"></i>
									系统接口申请表(模板)
								</el-link>
						</el-col>
					</el-row>
				</el-form>
			</div>
		</div>
		
		<div class="smp-result smp_panel_1"  v-else-if="fileList.length>0">
			<div class="smp_panel_header">
				<div class="smp_panel_pre"></div>
				<div class="smp_panel_title">附件信息</div>
				<div class="smp-panel_option">
				</div>
			</div>
			<div class="smp_panel_body">
				<el-form :inline="false" label-width="80px" size="mini" ref="form1">
					<el-row>
						<el-col :span="8">
							<el-form-item label="附件:" label-width="80px" prop="aa" style="text-align: left;">
								<div v-for="item in fileList" class="fileList">
									<el-link @click="downFile(item)" type="success" :underline="false"><i
											class="el-icon-document"></i> {{item.name}}</el-link>
								</div>
							</el-form-item>
						</el-col>
						
						
					</el-row>
				</el-form>
			</div>
		</div>

		<invocation ref="invocation" @getList="getList" />
		<system ref="system" @getList="getList" />
		<systemview ref="systemview" @getList="getList" />
		<registration ref="registration" @getList="getList" />
		<environment ref="environment" @getList="getList" />
		<network ref="network" />
		<applyServer ref="applyServer" />
		<versionField ref="versionField" />
		<commonInvocation ref="commonInvocation" @commonsubmit="commonsubmit" />
	</div>




</template>

<script>
	"use strict";
	import {
		selectAllByApplyId,
		appendixDown,
		generateAll,
		addAppendixSingle,
		deleteAppendixSingle,
		exportApplyService
	} from '@/api/demand.js';
	import {
		getEsbEnvironmentByEsbFlg
	} from '@/api/environment.js';
	import invocation from './components/invocation';
	import system from './components/system';
	import systemview from './components/systemview';
	
	import registration from './components/registration';
	import environment from './components/environment';
	import applyServer from './components/applyServer';
	import versionField from './components/versionField';
	import network from './components/network';
	import commonInvocation from './components/commonInvocation';
	
	import {
		getSystemInfoByPageNew,getSystemInfo
	} from '@/api/service.js';
	import {getFileDown} from '@/api/help.js';
	export default {

		components: {
			system,
			systemview,
			invocation,
			registration,
			environment,
			applyServer,
			network,
			versionField,
			commonInvocation
		},

		data() {

			return {
				esbEnvironmentList: [],
				that: this,
				applyID: 0,
				allList: {
					requireApply: {},
					applySystemCallList: [],
					applyServerList: [],
					applySystemList: [],
					applyEnvironmentList: []
				},
				applyServerListCurrentPage: 1,
				applyServerListPageSize: 5,
				applySystemCallListCurrentPage: 1,
				applySystemCallListPageSize: 5,
				activeUser:this.$store.getters.getActiveUser().userName,
				fileList: [],
				commonconfig:{}
			};
		},


		props: {
			row: {
				type: Object,
			},
			operate: {
				type: Boolean,
				default: false
			}
		},

		created() {
			this.applyID = this.row.sid;



			if (this.$route.query.applyServerListCurrentPage != undefined) {
				this.applyServerListCurrentPage = this.$route.query.applyServerListCurrentPage;
			}
			if (this.$route.query.applyServerListPageSize != undefined) {
				//this.query1.pageSize =this.$route.query.pageSize1;
				this.applyServerListPageSize = parseInt(this.$route.query.applyServerListPageSize);
			}


			if (this.$route.query.applySystemCallListCurrentPage != undefined) {
				this.applySystemCallListCurrentPage = this.$route.query.applySystemCallListCurrentPage;
			}
			if (this.$route.query.applySystemCallListPageSize != undefined) {
				//this.query1.pageSize =this.$route.query.pageSize1;
				this.applySystemCallListPageSize = parseInt(this.$route.query.applySystemCallListPageSize);
			}


			this.getEsbEnvironmentList();
			this.getList();

		},

		filters: {
			getESBEnvironment: function(ip, that) {

				let esbEnvironment = that.esbEnvironmentList.filter(item => item.ip == ip)[0];
				return esbEnvironment.ip + "(" + that.dictName(esbEnvironment.esbFlg, 'SMP0031') + ")";
			}
		},

		methods: {
			
			//下载模板
			downTemplate(){
				getFileDown({"fileName": "系统接口申请表.docx"}).then(res => {
					let name = "系统名称_需求编号_接口申请表.docx";
					let file = {
						uid: '-1', // 文件唯一标识，建议设置为负数，防止和内部产生的 id 冲突
						name:  "系统名称_需求编号_接口申请表.docx", // 文件名
						status: 'done', // 状态有：uploading done error removed
					}
					const blob = new Blob([res.data]);
					const blobURL = window.URL.createObjectURL(blob);
					const aLink = document.createElement('a');
					aLink.href = blobURL;
					aLink.setAttribute('download',name);
					
					if(typeof aLink.download==='undefined'){
						aLink.setAttribute('target','_blank');
					}
					aLink.style.display = 'none';
					document.body.appendChild(aLink);
					aLink.click();
					document.body.removeChild(aLink);
					window.URL.revokeObjectURL(blob);
				})
			},
			
			onapplyServerExport(){
				exportApplyService({"applyId":	this.applyID}).then(res => {
					let name = this.allList.requireApply.qmsNo+"_"+this.applyID+".xls";
					let file = {
						uid: '-1', // 文件唯一标识，建议设置为负数，防止和内部产生的 id 冲突
						name:   this.allList.requireApply.qmsNo+"_"+this.applyID+".xls", // 文件名
						status: 'done', // 状态有：uploading done error removed
					}
					const blob = new Blob([res.data]);
					const blobURL = window.URL.createObjectURL(blob);
					const aLink = document.createElement('a');
					aLink.href = blobURL;
					aLink.setAttribute('download',name);
					
					if(typeof aLink.download==='undefined'){
						aLink.setAttribute('target','_blank');
					}
					aLink.style.display = 'none';
					document.body.appendChild(aLink);
					aLink.click();
					document.body.removeChild(aLink);
					window.URL.revokeObjectURL(blob);
				})
			},
			
			
			getEsbEnvironmentList() {
				getEsbEnvironmentByEsbFlg({}).then(response => {
					this.esbEnvironmentList = response.data.extend;
				})
			},

			applyServerListCurrentChange(val) {

				this.applyServerListCurrentPage = val
				let query = this.$route.query;
				//Object.assign(query,this.query.body);
				query.applyServerListCurrentPage = this.applyServerListCurrentPage;
				query.applyServerListPageSize = this.applyServerListPageSize;

				this.$router.push({
					query: query
				}, () => {})
			},
			applyServerListSizeChange(val) {
				this.applyServerListCurrentPage = 1
				this.applyServerListPageSize = val
				let query = this.$route.query;
				//Object.assign(query,this.query.body);
				query.applyServerListCurrentPage = this.applyServerListCurrentPage;
				query.applyServerListPageSize = this.applyServerListPageSize;

				this.$router.push({
					query: query
				}, () => {})
			},

			applySystemCallListCurrentChange(val) {

				this.applySystemCallListCurrentPage = val
				let query = this.$route.query;
				//Object.assign(query,this.query.body);
				query.applySystemCallListCurrentPage = this.applySystemCallListCurrentPage;
				query.applySystemCallListPageSize = this.applySystemCallListPageSize;

				this.$router.push({
					query: query
				}, () => {})
			},
			applySystemCallListSizeChange(val) {
				this.applySystemCallListCurrentPage = 1
				this.applySystemCallListPageSize = val
				let query = this.$route.query;
				//Object.assign(query,this.query.body);
				query.applySystemCallListCurrentPage = this.applySystemCallListCurrentPage;
				query.applySystemCallListPageSize = this.applySystemCallListPageSize;

				this.$router.push({
					query: query
				}, () => {})


			},

			onSubmit() {
				generateAll({
					applyId: this.applyID
				}).then(response => {
					this.$message({
						duration: 5000,
						type: 'success',
						message: response.data.message,
					});
					this.getList();
				}).catch(error => {
					this.$message({
						duration: 5000,
						type: 'error',
						message: '配置失败',
					});
				});
			},
			
			
			
			changeFile(file, fileList) {
				//file.href=window.URL.createObjectURL(file.raw);
				//console.info(file.href);
				
				let data = new FormData();
				
			    data.append("file", file.raw);
				
			
				data.append("applyId", this.applyID);
				
				addAppendixSingle(data).then(res => {
					if (res.data.code == "0000") {
						this.fileList = this.fileList.filter(item => {
							return item.name != file.name
						})
						this.fileList.push(file);
					} else {
						this.$message.error(response.data.message);
					}
				});

			
			},
			
			beforUpload(file) {
				console.info("eee");
				let fileList1 = this.fileList.filter(item => {
					return item.name == file.name
				})
				if (fileList1.length > 0) {
					this.$message.error("附件已存在，请删除原有附件后上传");
					return false;
				}
			},
			
			deleteFile(file) {
				deleteAppendixSingle({
					applyId: this.applyID,
					fileName:file.name
				}).then(response => {
					this.$message({
						duration: 5000,
						type: 'success',
						message: "删除成功"
					});
					this.fileList = this.fileList.filter(item => {
						return item.name != file.name
					}) 
				}).catch(error => {
					this.$message({
						duration: 5000,
						type: 'error',
						message: '删除失败',
					});
				});
				
				/* this.fileList = this.fileList.filter(item => {
					return item.name != file.name
				}) */
			},

			downFile(file) {

				console.info("后台下载文件");

				appendixDown({
					fileName: file.name,
					applyId: this.applyID
				}).then(res => {

					let name = file.name;
					const blob = new Blob([res.data]);
					const blobURL = window.URL.createObjectURL(blob);
					const aLink = document.createElement('a');
					aLink.href = blobURL;
					aLink.setAttribute('download', name);

					if (typeof aLink.download === 'undefined') {
						aLink.setAttribute('target', '_blank');
					}
					aLink.style.display = 'none';
					document.body.appendChild(aLink);
					aLink.click();
					document.body.removeChild(aLink);
					window.URL.revokeObjectURL(blob);
				})
			},

			system(index, row) {
				let row1 = {};
				Object.assign(row1, row);
				this.$refs.system.showDialog(row1);
			},
			systemview(index, row){
				let row1 = {};
				Object.assign(row1, row);
				this.$refs.systemview.showDialog(row1);
			},

			registration(index, row) {
				let row1 = {};
				Object.assign(row1, row);
				this.$refs.registration.showDialog(row1);
			},

			environment(index, row) {
				let row1 = {};
				Object.assign(row1, row);
				this.$refs.environment.showDialog(row1);
			},

			network(index, row) {
				this.$refs.network.showDialog(row);
			},

			commonConfig() {
				this.$refs.commonInvocation.showDialog();
			},
			
			commonsubmit(row){
				this.commonconfig = row;
				this.allList.applySystemCallList.forEach((item)=>{
					Object.assign(item, row);
				});
			},

			invocation(index, row) {
				let row1 = {};
				Object.assign(row1, row);
				this.$refs.invocation.showDialog(row1);
			},


			getList() {
				selectAllByApplyId({
					id: this.applyID
				}).then(response => {
					//this.allList = response.data.extend;
					let obj = response.data.extend;
					this.allList.requireApply = obj.requireApply;
					this.allList.applySystemList = obj.applySystemList
					this.allList.applyServerList = obj.applyServerList
					this.allList.applySystemCallList = obj.applySystemCallList
					this.allList.applyEnvironmentList = obj.applyEnvironmentList
					this.fileList = [];
					obj.applyAppendixList.forEach(item => {
						this.fileList.push({
							name: item.fileName
						});
					})
					
					this.allList.applySystemCallList.forEach((item)=>{
						Object.assign(item, this.commonconfig);
					});


				}).catch(error => {
					console.info("失败");
					console.info(error.message);
				});

			},


			handleEdit2(index, row) {
				let row2 = {};
				Object.assign(row2, row);
				let index1 = (this.applyServerListCurrentPage - 1) * this.applyServerListPageSize + index;
				this.$refs.applyServer.showDialog2(row2, index1);
			},


			handleEdit1(index, row) {
				getSystemInfo( {
						"systemNo": row.systemNo
				}).then(response => {
					let system = response.data.extend;
					this.$router.push({
						name: 'systemDetails',
						query: Object.assign(system)
					})
				}).catch(error => {
					console.info("失败");
					console.info(error.message);
				});
			},

			handleEdit3(index, row) {
				this.$router.push({
					name: 'serviceDetails',
					query: {
						"busCode": row.busCode,
						"transCode": row.transCode,
						"systemNo": row.systemNo
					}
				})
			},

			handleEdit4(index, row) {
				this.$router.push({
					name: 'serviceDetails',
					query: {
						"busCode": row.regCode,
						"transCode": row.transCode,
						"systemNo": row.regSysCode
					}
				})
			},

			versionComparison(index, row) {
				let row2 = {};
				Object.assign(row2, row);
				let index1 = (this.applyServerListCurrentPage - 1) * this.applyServerListPageSize + index;

				this.$refs.versionField.showDialog2(row2, index1);
			},

		}
	}
</script>

<style>
	.detailsTitle {
		color: black;
		font-size: 18px;
		text-align: left;
		margin-top: 15px;
		margin-left: 0px;
		margin-bottom: 10PX;
		border-left: 3px solid #090;
		line-height: 24px;
		padding-left: 10px;
		color: #57595d;
	}

	.serviceInfo {
		text-align: left;
		margin-left: 40px;
	}

	.serviceInfo span {
		line-height: 30px;
		text-align: left;
		color: #606266;
		font-size: 14px;
	}


	.proxyPathClass .el-tooltip {
		
		color: #67c23a;
		
	}
</style>
